package com.habdqn.attendance.service.impl;

import com.habdqn.attendance.entity.WorkingShift;
import com.habdqn.attendance.dao.WorkingShiftDao;
import com.habdqn.attendance.service.WorkingShiftService;

import java.util.List;

/**
 * 班次表(WorkingShift)表服务实现类
 *
 * @author makejava
 * @since 2019-10-23 14:35:17
 */
public class WorkingShiftServiceImpl implements WorkingShiftService {
    private WorkingShiftDao workingShiftDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public WorkingShift queryById(Integer id) {
        return this.workingShiftDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<WorkingShift> queryAllByLimit(int offset, int limit) {
        return this.workingShiftDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param workingShift 实例对象
     * @return 实例对象
     */
    @Override
    public WorkingShift insert(WorkingShift workingShift) {
        this.workingShiftDao.insert(workingShift);
        return workingShift;
    }

    /**
     * 修改数据
     *
     * @param workingShift 实例对象
     * @return 实例对象
     */
    @Override
    public WorkingShift update(WorkingShift workingShift) {
        this.workingShiftDao.update(workingShift);
        return this.queryById(workingShift.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.workingShiftDao.deleteById(id) > 0;
    }
}